<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/pravate/commen.css" />
		<link rel="stylesheet" href="../css/pravate/details.css" />
		<script type="text/javascript" src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/jquery-2.1.0.js"></script>
		<script type="text/javascript" src="../js/mobile-detect.min.js"></script>
		<script type="text/javascript" src="../js/config.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>

	</head>
	<style>
		.Btn {
			width: 100%;
			padding: 15px;
			margin-top: 30px;
			font-size: 0;
		}
		
		.Btn button {
			padding: 12px 0;
			border-radius: 5px;
		}
		
		.Btn button:first-child {
			width: 40%;
			margin-right: 5%;
		}
		
		.Btn button:last-child {
			width: 55%;
		}
		.password{
			margin-top: 15px;
		}
		.print{
			line-height: 44px;
			color: #000;
			font-size: 16px;
		}
	</style>

	<body>
		<header class="mui-bar mui-bar-nav" style="border-bottom: 1px solid #E7E7E7;">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">详情</h1>
			<a class="mui-pull-right print">打印</a>
		</header>
		<div class="mui-content">
			<div class="bg-f4f4f4">
				<div class="bg-fff">
					<div class="mui-row mui-linehieght-30 border-bottom-e7e7">
						<div class="mui-col-sm-6 mui-col-xs-6 text-sm text-999 out_order_no"></div>
						<div class="mui-col-sm-6 mui-col-xs-6 text-sm">
							<span class="mui-pull-right text-primary pay_status"></span>
						</div>
					</div>
					<div class="mui-row mui-linehieght-30">
						<div class="mui-col-sm-5 mui-col-xs-5 text-sm text-666">入住人信息</div>
						<div class="mui-col-sm-7 mui-col-xs-7 text-sm">
							<span class="mui-pull-right text-333 BookingName"></span>
						</div>
					</div>
					<div class="mui-row mui-linehieght-30">
						<div class="mui-col-sm-5 mui-col-xs-5 text-sm text-666">入住时间</div>
						<div class="mui-col-sm-7 mui-col-xs-7 text-sm">
							<span class="mui-pull-right text-333 BookingTime"></span>
						</div>
					</div>
					<div class="mui-row mui-linehieght-30">
						<div class="mui-col-sm-5 mui-col-xs-5 text-sm text-666">总计</div>
						<div class="mui-col-sm-7 mui-col-xs-7 text-sm">
							<span class="mui-pull-right text-333 amount"></span>
						</div>
					</div>
					<div class="mui-row mui-linehieght-30 border-bottom-e7e7">
						<div class="mui-col-sm-5 mui-col-xs-5 text-sm text-666">备注</div>
						<div class="mui-col-sm-7 mui-col-xs-7 text-sm">
							<span class="mui-pull-right text-333 remarks"></span>
						</div>
					</div>
					<div class="mui-row mui-linehieght-30">
						<div class="mui-col-sm-5 mui-col-xs-5 text-sm text-666">收信人号码</div>
						<div class="mui-col-sm-7 mui-col-xs-7 text-sm">
							<span class="mui-pull-right text-999 text-xs ReceivePhone"></span>
						</div>
					</div>
				</div>
				<div class="mui-row" style="padding: 10px 0;">
					<div class="mui-col-sm-6 mui-col-xs-6 text-sm text-999">已发送短信</div>
					<div class="mui-col-sm-6 mui-col-xs-6">
						<span class="mui-pull-right text-999 text-sm created_at"></span>
					</div>
				</div>
				<div class="details" style="background: #fff;">
					<div class="mui-row">
						<div class="mui-col-sm-12 mui-col-xs-12 SmsCentent" style="word-wrap:break-word;"></div>
					</div>
				</div>
				<div class="Btn">
					<button class="mui-btn mui-btn-warning">重发短信</button>
					<button class="mui-btn mui-btn-primary" style="background: rgb(27,129,210);">核对到店</button>
				</div>
			</div>
		</div>
		<script type="text/javascript" charset="utf-8">
			mui.init();
			mui.plusReady(function() {
				console.log(localStorage.getItem("token"));
				notice_websokit();
				var self = plus.webview.currentWebview();
				var out_order_no = self.out_order_no;
				require(weburl + SmsAuthDetail, "json", "post", {
					out_order_no: out_order_no,
					token: localStorage.getItem("token")
				}, function(response) {
//					alert(JSON.stringify(response));
					var response = response.data[0];
					$(".BookingName").html(response.BookingName + "(" + response.BookingPhone + ")");
					$(".ReceivePhone").html(response.ReceivePhone);
					$(".created_at").html(response.created_at);
					$(".remarks").html(response.remarks);
					$(".BookingTime").html(response.BookingTime);
					$(".SmsCentent").html(response.SmsCentent);
					$(".out_order_no").html(response.out_order_no);
//					$(".pay_status").html(payStatus(response.pay_status));
					$(".pay_status").html(response.StatusTypeText);
					$(".amount").html('￥'+response.amount);
					if(response.traceNo_Status==1){
						$(".Btn button").css("background","#B9B9B9");
						$(".Btn button").attr("disabled","disabled");
						$(".Btn button").css("border","1px solid #B9B9B9");
					}
				}, function() {
					mui.alert("网络错误，请稍后再试", " ", "关闭", function() {}, "div");
				})
				
				function payStatus(num){
					var sta = "";
					console.log(num);
					switch(num) {
						case 1:
							sta = "已支付";
							break;
						case 2:
							sta = "已取消";
							break;
						case 3:
							sta = "待支付";
							break;
						case 4:
							sta = "已结算";
							break;
					}
					return sta;
				}
				
				//重发短信
				mui("body").on("tap", ".Btn button:first-child", function() {
					mui.confirm("<p style='color:red;font-size:14px;margin-top:15px;'>重新发送短信的时间间隔为2分钟</p>", "是否重发短信", ["发送", "取消"], function(e) {
						if(e.index == 0) {
							plus.nativeUI.showWaiting("正在重新发送短信...");
							require(weburl + SmsReSend, "json", "post", {
								out_order_no: out_order_no,
								token:localStorage.getItem("token")
							}, function(response) {
								plus.nativeUI.closeWaiting();
								mui.alert(response.msg, " ", "关闭", function() {}, "div");
							}, function() {
								plus.nativeUI.closeWaiting();
								mui.alert("网络错误，请稍后再试", " ", "关闭", function() {}, "div");
							})
						}
					}, "div")
				})
				
				//确认核销
				mui("body").on("tap",".Btn button:last-child",function(){
					mui.confirm("是否确认到店", " ", ["确认", "取消"],function(e){
						if(e.index==0){
							plus.nativeUI.showWaiting("正在操作中，请勿退出...");
							$("input").blur();
							require(weburl+OrderVerify,"json","post",{
								token:localStorage.getItem("token"),
								out_order_no: out_order_no
							},function(response){
								plus.nativeUI.closeWaiting();
								if(response.status=="success"){
									mui.alert(response.msg, " ", "关闭", function() {
										window.location.reload();
									}, "div");
									return false;
								}
								mui.alert(response.msg, " ", "关闭", function() {}, "div");
							},function(){
								plus.nativeUI.closeWaiting();
								mui.alert("网络错误，请稍后再试", " ", "关闭", function() {}, "div");
							})
						}
					},"div");
				})
				var signDy=true;
				//打印订单
				mui("body").on("tap",".print",function(){
					mui.confirm("是否打印小票"," ",["打印","关闭"],function(ev){
						var xSign=true;
						if(ev.index==0){
							if(signDy==true){
								require(weburl + SmsAuthDetail, "json", "post", {
									out_order_no: out_order_no,
									token: localStorage.getItem("token"),
									print_status:"1"
								}, function(response) {
									console.log(JSON.stringify(response));
									signDy=false;
									if(response.status=="success"){
										setTimeout(function(){signDy=true;},3000);
										var str = response.data[0].print_body;
										var reg = /\\n/g;
										str = str.replace(reg, '\n');
										printTicket(response.data[0].print_array);
//										ticket(response.data[0].store_name, str, response.data[0].out_order_no);
									}else{
										signDy=true;
										mui.alert(response.msg," ","关闭",function(){xSign=false;},"div");
									}
									
								}, function() {
									mui.alert("网络错误，请稍后再试", " ", "关闭", function() {xSign=false;}, "div");
								})
							}
							setTimeout(function(){
								console.log(1);
								if(xSign==true){
									return false;
								}
							},0);
							
							
						}
					},"div")
					
				})
				function pay_status(num){
					var str=""; 
					switch (num){
						case "1":
							break;
						case "2":
							break;
						case "3":
							break;
						case "4":
							break;
					}
					return str;
				}

			})
		</script>
	</body>

</html>